/**
 * Copyright (c) 快宝网络 kuaidihelp.com Co., Ltd. All Rights Reserved 禁止外泄以及用于其它的商业用途
 */

import request from '@/utils/request';
import { isArray } from 'lodash';

export async function getFeedbackList(params: any, cb?: (list: any[]) => void): Promise<any> {
  return request('/courier/feedbackList', {
    method: 'POST',
    data: params,
  }).then(({ data }) => {
    const { list, page, total } = data || {};
    if (isArray(list) && list.length > 0) {
      if (cb) {
        cb(list);
      }
      return {
        total,
        success: true,
        data: list,
        page,
      };
    }
    return {};
  });
}

// 意见反馈，保存意见
export async function saveFeedback(params: any) {
  return request('/courier/feedbackDeal', {
    data: params,
    method: 'POST',
  });
}

// 意见反馈，忽略意见
export async function ignoreFeedback(params: any) {
  return request('/courier/feedbackReply', {
    data: params,
    method: 'POST',
  });
}
